<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<div id="examrecordsGrid"></div>
<div id="examrecordsToolbar">
<div>
        <a href="#" class="easyui-linkbutton" onclick="examrecords.toolbar.remove();" data-options="
        iconCls:'icon-remove',
        plain:true">
            删除
        </a>
        <a href="#" class="easyui-linkbutton" onclick="examrecords.toolbar.redo();" data-options="
        iconCls:'icon-redo',
        plain:true">
            取消
        </a>
    </div>

	<div>
		<strong>学员名称：</strong>
		<input type="text" name="searchName" id="searchName" class="easyui-textbox"/>
		<strong>试卷名称:</strong> 
		  	<input name="course_id" style="width:10%" class="easyui-combobox" id="papername_choose" data-options="
			valueField: 'name',
  		    textField: 'name',
  		    url: '<%=request.getContextPath()%>/exam/ExamRecordsServlet?command=listpapername',
			editable: false" />
		<a href="#" class="easyui-linkbutton" onclick="examrecords.toolbar.search()" data-options="
		iconCls:'icon-search',
		plain:true">
			查询
		</a>
	</div>
		<div id="confirmState" class="easyui-window" title="提示" data-options="iconCls:'icon-save',closed:true" style="width:300px;height:150px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;text-align:center">
				是否修改状态？
			</div>
			<div data-options="region:'south',border:false" style="text-align:center;padding:5px 0 0;">
				<a class="easyui-linkbutton" style="padding:0 10px" data-options="iconCls:'icon-ok'" onclick="examrecords.confirm()"  style="width:80px">是</a>
				<a class="easyui-linkbutton" style="padding:0 10px" data-options="iconCls:'icon-cancel'" onclick="$('#confirmState').window('close')" style="width:80px">否</a>
			</div>
		</div>
	</div>
</div>
<script>
	var examrecords = {
		init : function() {
			examrecords.examrecordsGrid = $('#examrecordsGrid');
			examrecords.menu = $('#menu');
			examrecords.examrecordsAddForm = $('#examrecordsAddForm');
			examrecords.examrecordsUpdateForm = $('#examrecordsUpdateForm');
			examrecords.menuUpdate = $('#menuUpdate');
			examrecords.examrecordsUpdateDialog = $('#examrecordsUpdateDialog');
			examrecords.examrecordsGrid.datagrid({
			    url: '<%=request.getContextPath()%>/exam/ExamRecordsServlet?command=listExamRecords',
			    fitColumns: true,
			    striped: true,
			    rownumbers: true,
			    pagination: true,
			    pageSize: 20,
			    pageList: [10, 20, 30, 40, 50],
			    pageNumber: 1,
			    sortName: 'age',
			    sortOrder: 'desc',
			    toolbar: '#examrecordsToolbar',
			    columns:[[
					{field:'id', width:100, checkbox: true},
					{field:'sysUser_name', title:'学员名称', width:80, align:'center'},
					{field:'qesExamPaper_name', title:'试卷名称', width:80, align:'center'},
					{field:'startTimeFormat', title:'开始时间', width:80, align:'center'},
					{field:'submitTimeFormat', title:'提交时间', width:80, align:'center'},
					{field:'qesExamPaper_totalPoint', title:'总分分数', width:80, align:'center'},
			    	{field:'getPoint', title:'得分数', width:80, align:'center'},
			    	{field:'isPassStr', title:'状态', width:80, align:'center'},
			    ]],
				onDblClickRow: function(rowIndex, rowData) {
					examrecords.toolbar.showUpdateDialog(rowData.id);
				}
			});
		},
		
		toolbar: {
			showCombotree: function() {
				examrecords.menu.combotree({
					lines: true,
					multiple: true,
					checkbox: true,
					onlyLeafCheck: true,
					onLoadSuccess: function(node, data) {
						$(this).tree('expandAll')
					}
				});
			},
			search:function(){
				var searchName = $("#searchName").textbox('getValue');
				var papername_choose = $('#papername_choose').combobox('getValue');
				examrecords.examrecordsGrid.datagrid({
					url: '<%=request.getContextPath() %>/exam/ExamRecordsServlet?command=search',
					queryParams:{
						"searchName": searchName,
						"papername_choose" : papername_choose}, 
						fitColumns: true,
					    striped: true,
					    rownumbers: true,
					    pagination: true,
					    pageSize: 20,
					    pageList: [10, 20, 30, 40, 50],
					    pageNumber: 1,
					    sortName: 'age',
					    sortOrder: 'desc',
					    toolbar: '#examrecordsToolbar',
					    columns:[[
								{field:'id', width:100, checkbox: true},
								{field:'sysUser_name', title:'学员名称', width:80, align:'center'},
								{field:'qesExamPaper_name', title:'试卷名称', width:80, align:'center'},
								{field:'startTimeFormat', title:'开始时间', width:80, align:'center'},
								{field:'submitTimeFormat', title:'提交时间', width:80, align:'center'},
								{field:'qesExamPaper_totalPoint', title:'总分分数', width:80, align:'center'},
								{field:'getPoint', title:'得分数', width:80, align:'center'},
								{field:'isPassStr', title:'状态', width:80, align:'center'},
							
					    ]],
						onDblClickRow: function(rowIndex, rowData) {
							examrecords.toolbar.showUpdateDialog(rowData.id);
						}	
				})
			},
			
			hiddenUpdateDialog: function() {
				$('#examrecordsUpdateDialog').dialog('close');
				examrecords.toolbar.resetUpdateFrom();
			},
			resetUpdateFrom: function() {
				examrecords.examrecordsUpdateForm.form('reset');
			},
			remove: function() {
				var row = examrecords.examrecordsGrid.datagrid('getSelections');
				if (row.length > 0) {
					var ids = [];
					$.each(row, function(i, v) {
						ids.push(v.id);
					});
					$.post('<%=request.getContextPath()%>/exam/ExamRecordsServlet?command=deleteExamRecords', {ids: ids.join(',')}, function(data) {
						if (data == 1) {
							$.messager.show({
								title: '系统提示',
								msg: '删除成功！',
								timeout: 3000,
								showType: 'slide'
							});
							examrecords.examrecordsGrid.datagrid('reload');
						} else {
							$.messager.alert('系统提示', '删除失败！', 'error')
						}
						$.messager.progress('close');
					});
				} else {
					$.messager.show({
						title: '系统提示',
						msg: '请选择数据进行删除！',
						timeout: 3000,
						showType: 'slide'
					});	
				}
			},
			redo: function() {
				examrecords.examrecordsGrid.datagrid('unselectAll');
			},
		}
	};
	
	$(function(){
		examrecords.init();
	});
</script>